home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / 4dostool / bkup10.zip / BKUP10.BTM < prev    next >
Text File  |  1994-05-18  |  23KB  |  824 lines

  1. :: ------------------------------------------------------------------
  2. :  BKUP.BTM, version 10, May 5, 1994
  3. :  Read BKUP.DOC for detailed description, or type BKUP H
  4. :  Call BKUP.INI to modify defaults.
  5. :: ------------------------------------------------------------------
  6. :  This is the main BKUP batch. See BKUP.LST for a full list.
  7. :: ------------------------------------------------------------------
  8. :  Itamar Even-Zohar (itamarez@plato.tau.ac.il)
  9. :: ------------------------------------------------------------------
  10.  
  11. :2help  :: (displays HELP if you type H, ?, or /?, or I)
  12. iff %@index[%1,h] eq 0 .or. %@index[%1,?] ge 0 .or. %@index[%1,i] eq 0 then
  13. call bk-hlp.btm %1
  14. endiff
  15.  
  16. iff %_4ver lt 5 then
  17. cls
  18. beep
  19. screen 2 0
  20. text
  21.     This version of BKUP does not support 4DOS version 4.x.
  22.     Please use previous versions.
  23. endtext
  24. cancel
  25. endiff
  26.  
  27. setlocal
  28. set args=%1&
  29.  
  30. gosub bk-prams
  31. :: (bk-prams.btm checks and sets various parameters)
  32.  
  33. :ex_choice
  34. :: (if x or -x specified, the extraction part will work)
  35. iff %@index[%1,x] ge 0 .and. %@index[%1,x] lt 2 then
  36.   goto extract_f
  37. endiff
  38.  
  39. gosub check_args
  40. :: (defining drives for opeations if not defined elsewhere)
  41.  
  42. :check_compu
  43. :: (checking computer's "name")
  44. if "%compuname"=="" gosub compuname
  45. ::goto set_params
  46.  
  47. :get_date  :: (separates typed date from -s or s ["since"] in date)
  48. iff %@index[%1,/s] ge 0 .or. %@index[%1,-s] ge 0 then
  49.    set date0=%@substr[%1,2]
  50.    goto set_defaults
  51. elseiff %@index[%1,s] eq 0 then
  52.    set date0=%@substr[%1,1]
  53.    goto set_defaults
  54. else
  55.    goto compu_date
  56. endiff
  57.  
  58. :compu_date
  59. set days=%@date[%_date]
  60. :      This is today'y date in full numbers since 1-1-1980
  61. set date0=%@makedate[%@eval[%days-%1]]
  62. :      This is the actual date desired for the archive file.
  63. :      If no number of days indicated by user, you get today's
  64. :      date again.
  65. if %@index[%date0,0] eq 0 set date0=%@substr[%date0,1]
  66. :      If a zero (0) is contained on the first position (01, etc.),
  67. :      it will be removed.
  68.  
  69. :set_defaults
  70. :: (setting: temporary archive name, final archive name;
  71. :: removing: old temporary archive; verifying: colors for message)
  72. ::
  73. set rsp=%temp%upd.rsp
  74. set zipfn=%temp%upd.%zip_ext
  75. set tmpf=%@unique[%temp]
  76. if exist %zipfn del /q %zipfn
  77. :: (This is just a precaution; this file is moved anyway, if batch
  78. :: terminates in a normal way.)
  79. if .%colordir==. set colordir=dirs:bright white;zip uc:black on white;
  80.  
  81. :re-use?  :: (Use again the updates file or create a new one?)
  82. cls
  83. if exist %rsp goto ask
  84. goto accumulate
  85.  
  86. :ask
  87. :: (use extant list of updates or create a new one?)
  88. echo.
  89. gosub legenda
  90. screen 2 0
  91. inkey /K"YNVESQ" Use extant list file? (created %@filedate[%rsp], at %@filetime[%rsp])? [time now: %_time]n (List File is: %@upper[%rsp])nnType Y/N, V(iew), S(creen), E(dit), or Q(uit) %%rep
  92.     iff %rep == Q then cls^screen 2 0^set ech=echo Stopped by user^ goto end
  93. elseiff %rep == Y then goto backup
  94. elseiff %rep == V then *list %rsp^cls^goto ask
  95. elseiff %rep == E then %edt %rsp^goto backup
  96. elseiff %rep == S then echo. >%tmpf^cls^set num=0^goto edit
  97. elseiff %rep == N goto accumulate
  98. endiff
  99.  
  100. :accumulate
  101. cls
  102.   iff %_monitor == mono then
  103. screen 4 5 [ making a list of all new files created since %date0 ]
  104. screen 3 5 Working ...
  105.   else
  106. scrput 4 5 gre on whi [ making a list of all new files created since %date0 ]
  107. scrput 3 5 blu on whi  Working ...
  108.   endiff
  109.  
  110. :make_list
  111. :: (Create the updates file with 4DOS internal dir /d command
  112. :: [valid only from version 5.x])
  113. cdd %search_drive:\
  114. dir /bsa:a /[d%date0] >%rsp
  115.  
  116. :check_list
  117.   iff %@lines[%rsp] lt 0 then
  118.   set ech=scrput 3 17 bri whi on bla No files were found for/since %date0!
  119.   del /q %rsp
  120.   goto end
  121.   endiff
  122. scrput 3 17 bri whi on bla List created as %@upper[%rsp]
  123.  
  124. :edit?
  125. screen 6 5 Select an option (press first letter):
  126. screen 7 5
  127. text
  128.  
  129.    Screen  select files on screen (one file after another)
  130.            (this option allows viewing and deleting)
  131.    Edit    edit results file via editor
  132.    View    view results before making any decision
  133.    Go      go to immediate archiving (no selection)
  134.    Quit    stop now (results file will remain intact)
  135. endtext
  136. screen 16 3
  137. inkey /K"SEQGV[ESC][Enter]" Your choice?  %%rep
  138. iff %rep == G then goto backup
  139.   elseiff %rep == S .or. %rep == @28 then
  140.     echo. >%tmpf
  141.     cls
  142.     set num=0
  143.     goto edit
  144.   elseiff %rep == E then
  145.     %edt %rsp
  146.     goto backup
  147.   elseiff %rep == V then
  148.     *list %rsp
  149.     cls^goto edit?
  150.   elseiff %rep == Q .or. %rep == %@char[27] then
  151.     set ech=echo Stopped by user^goto end
  152. endiff
  153.  
  154. :edit
  155. rem   This procedure displays all the files saved today, one by one,
  156. :     allowing you to (a) select only those you wish to back up, or
  157. :     (b) delete, or (c) view a file before making a decision, or
  158. :     (d) view the list of selections, or (e) stop selecting and go
  159. :     to immediate archiving, or (f) quit.
  160. :
  161. iff %@eval[%num] gt %@lines[%rsp] then
  162.   move /q %tmpf %rsp
  163.   goto backup
  164.   endiff
  165. set fn=%@line[%rsp,%num]
  166. if .%fn==. (set num=%@eval[%num+1]^goto edit)
  167. scrput 0 0 black on white  Accept=A/enter Omit=O/Esc D=Delete V=View G=Begin archiving L=View list Q=Quit 
  168. echo.
  169.   iff %_row lt 2 then
  170.   screen 2 0
  171.   endiff
  172. echo ==`>` %fn
  173.   iff %_row ge %@eval[%_rows -1] then
  174.   cls
  175.   goto edit^endiff
  176. inkey /K"YNAODVGLQ[ESC][Enter]" A(ccept)? O(mit)? D(elete)? V(iew)? G(o)? (L)ist Q(uit)?  %%rep
  177. iff %rep == %@char[27] .or. %rep == O .or. %rep == N then
  178.      set num=%@eval[%num +1]
  179.      goto edit
  180.      :REM: see label ':note' below
  181. elseiff %rep == A .or. %rep == @28 .or. %rep == Y then
  182.      echo %fn >>%tmpf
  183.      set num=%@eval[%num +1]
  184.      goto edit
  185. elseiff %rep == D then
  186.      del /q %fn
  187.      echo ==`>` %fn deleted^echo.
  188.      set num=%@eval[%num +1]
  189.      goto edit
  190. elseiff %rep == V then
  191.      *list %fn
  192.      echo.^goto edit
  193. elseiff %rep == G then
  194.      set num=%@eval[%@lines[%rsp]+1]
  195.      goto edit
  196. elseiff %rep == L then
  197.      *list %tmpf
  198.      echo.^goto edit
  199. elseiff %rep == Q then set ech=echo Stopped by user^goto end
  200. endiff
  201.  
  202. :backup
  203. cdd %temp
  204. rem  (Checking if there are any file at all to back up)
  205.   gosub void
  206.   
  207. :update
  208. rem  (If zip archive exists on target diskette, update it)
  209. cls^echo.^echo.
  210. gosub check_drive
  211. iff exist %dr:\%date0.%zip_ext then
  212. set fn=%dr:\%date0.%zip_ext
  213. set state=old
  214. :: (The following 2 lines are just to remind the reader of parameters
  215. :: set up in BK-PRAMS.BTM.)
  216. :: if "%zip_pgm"=="zip"   set pkz=zip -uk -b%temp -9
  217. :: if "%zip_pgm"=="pkzip" set pkz=pkzip -b%temp -P -u -ex
  218. cls
  219. screen 2 0
  220. gosub void
  221. if "%zip_pgm"=="zip"   set pkz=%pkz %dr:\%date0.%zip_ext -@ `<`%rsp %exclude `>&>`nul
  222. if "%zip_pgm"=="pkzip" set pkz=%pkz %exclude %dr:\%date0.%zip_ext @%rsp
  223. if "%zip_pgm"=="uc"    set pkz=%pkz %dr:\%date0.%zip_ext @%rsp %exclude
  224.  
  225. :: (execute compression now)
  226.  
  227. %pkz
  228. gosub success
  229. goto end
  230. endiff
  231.  
  232. :create_zip
  233. cls
  234. screen 2 0
  235. gosub void
  236. if "%zip_pgm"=="zip"   set pkz=%pkz %zipfn -@ `<`%rsp %exclude `>&>`nul
  237. if "%zip_pgm"=="pkzip" set pkz=%pkz %exclude %zipfn @%rsp
  238. if "%zip_pgm"=="uc"    set pkz=%pkz %zipfn @%rsp %exclude
  239. ::
  240. :: (execute compression now)
  241. %pkz
  242. gosub success
  243.  
  244. :check_room
  245. rem  (Checking if there is room for backup file on target)
  246. iff %@diskfree[%dr:,b] lt %@filesize[%zipfn,b] then
  247. set ech=Echo No room on drive %@upper[%dr:]! %zipfn was left on %temp
  248.   goto end
  249.   else
  250. set ech=echo Backup archive created on drive %@upper[%dr:]
  251. endiff
  252.  
  253. :move_zip
  254. gosub check_drive
  255. move /q %zipfn %dr:\%date0.%zip_ext
  256. set brand=upd
  257. set fn=%dr:\%date0.%zip_ext
  258. gosub brand
  259.  
  260. :end
  261. if exist %tmpf del /q %tmpf
  262. if exist %excls_file del /q %excls_file
  263. echo.
  264. %ech
  265. echo.
  266.   iff %@index[%ech,Stopped] ge 0 then goto interrupt
  267.   elseiff %@index[%ech,No new] ge 0 then goto interrupt
  268.   elseiff %@index[%ech,No files we] ge 0 then goto interrupt
  269.   elseiff %@index[%ech,could not be] ge 0 then goto interrupt
  270.   endiff
  271. if exist %dr:\%date0.%zip_ext dir /klm %dr:\%date0.%zip_ext
  272. echo.
  273. :interrupt
  274. endlocal
  275. quit
  276.  
  277. ::*===========End of archiving part===================*::
  278.  
  279.